package com.wolfheader.wolfgame.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.PrePersist;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Entity - 玩家用户
 * 
 * @author 8615 Team
 * @version 1.0
 */
@Entity
@Table(name = "t_game_player")
@SequenceGenerator(name = "sequenceGenerator", sequenceName = "game_gamePlayer_sequence")
public class GamePlayerEntity extends BaseEntity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 205502645186924066L;

	/**
	 * 唯一ID
	 */
	private String openid;

	/**
	 * 用户昵称
	 */
	private String nickname;

	/**
	 * 头像
	 */
	private String avatar;

	/**
	 * 帐号
	 */
	private String username;

	/**
	 * 密碼
	 */
	private String password;

	/**
	 * 通行卡
	 */
	private Integer card;

	/**
	 * 登陸次數
	 */
	private Integer loginTime;

	/**
	 * 上次登錄時間
	 */
	private Date lastLoginDate;

	/**
	 * 是否啓用
	 */
	private Integer enabled;

	private String realname;

	private String phone;

	private String address;

	private String playerId;

	@Column(nullable = false, updatable = false, unique = true)
	public String getPlayerId() {
		return playerId;
	}

	public void setPlayerId(String playerId) {
		this.playerId = playerId;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Integer getCard() {
		return card;
	}

	public void setCard(Integer card) {
		this.card = card;
	}

	public Integer getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(Integer loginTime) {
		this.loginTime = loginTime;
	}

	public Date getLastLoginDate() {
		return lastLoginDate;
	}

	public void setLastLoginDate(Date lastLoginDate) {
		this.lastLoginDate = lastLoginDate;
	}

	public Integer getEnabled() {
		return enabled;
	}

	public void setEnabled(Integer enabled) {
		this.enabled = enabled;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	@JsonProperty
	@Column(nullable = false, updatable = false, unique = true)
	public String getOpenid() {
		return openid;
	}

	public void setOpenid(String openid) {
		this.openid = openid;
	}

	@JsonProperty
	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getRealname() {
		return realname;
	}

	public void setRealname(String realname) {
		this.realname = realname;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	/**
	 * 持久化前处理
	 */
	@PrePersist
	public void prePersist() {
		setPhone("");
		setAddress("");
		setRealname("");
	}
}
